home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / intersectPreset.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.5 KB  |  130 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Mar 20, 1997
  22. //  Author:        RS 
  23. //
  24. //  Description:
  25. //      The intersectPreset() procedure executes a intersect operation on 
  26. //      a pair of surfaces based on the intersect option vars. In general if
  27. //        you have n surfaces selected, (n-1) surface intersect operations would 
  28. //        be carried out.
  29. //
  30. //  Input Arguments:
  31. //      None.
  32. //
  33. //  Return Value:
  34. //      None.
  35. //
  36.  
  37. proc string pieceTogetherACmd(
  38.     int $cosOnlyOnFirstSurface,
  39.     int $cosAs2D,
  40.     int $history,
  41.     float $tol )
  42. //
  43. //    Description :
  44. //        piece together an intersect command.
  45. //
  46. {
  47.     string $cmd;
  48.     $cmd = "intersect " ;
  49.  
  50.     // construction history.
  51.     //
  52.     $cmd = $cmd + " -ch " ;
  53.  
  54.     if( $history == 1 ) {
  55.         $cmd = $cmd + "true" ;
  56.     } else {
  57.         $cmd = $cmd + "false" ;
  58.     }
  59.  
  60.     $cmd = $cmd + " -fs " ;
  61.     $cmd = $cmd + $cosOnlyOnFirstSurface ;
  62.  
  63.     $cmd = $cmd + " -cos " ;
  64.     $cmd = $cmd + $cosAs2D ;
  65.  
  66.     $cmd = $cmd + " -tol " + $tol ;
  67.  
  68.     return $cmd ;
  69.  
  70. }
  71.  
  72. global proc intersectPreset(
  73.  int $cosOnlyOnFirstSurface,
  74.  int $cosAs2D,
  75.  int $history,
  76.  float $tol )
  77. //
  78. //    Intersect with the preset options.
  79. //    Use this proc when operation dragged to Shelf.
  80. //
  81. {
  82.     string $cmd ;
  83.     $cmd = pieceTogetherACmd( $cosOnlyOnFirstSurface, $cosAs2D, $history, $tol ) ;
  84.  
  85.     int $nitems = 2 ;
  86.     $cmd = appendToCmdPlaceHoldersForSelectionItems($cmd,$nitems) ;
  87.  
  88.     // Get the list of nurbs surfaces selected.
  89.     //
  90.     global int $gSelectNurbsSurfacesBit;
  91.     string $surfaceList[] = `filterExpand -ex true -sm $gSelectNurbsSurfacesBit`;
  92.     int $i ;
  93.  
  94.     int $surfaceCount = size($surfaceList) ;
  95.     if( $surfaceCount < 2 ) {
  96.        error "Select at least two NURBS surfaces to intersect" ; 
  97.     } else {
  98.         // all (n-1) combinations
  99.         //
  100.         string $intersectResults[] ;
  101.         int $nr = size($intersectResults) ;
  102.         for( $i = 0 ; $i < $surfaceCount-1 ; $i++ ) {
  103.             string $surfacePair[2] ;
  104.             $surfacePair[0] = $surfaceList[$i] ;
  105.             $surfacePair[1] = $surfaceList[$surfaceCount-1] ;
  106.             string $results[] = executeCmdOnItems( $cmd, $surfacePair );    
  107.             $intersectResults = stringArrayCatenate( $intersectResults, $results ) ;
  108.         } // for $i    
  109.  
  110.         // select the results.
  111.         //
  112.         int $resultCount = size($intersectResults) ;
  113.  
  114.         if( $resultCount > 0 ) {
  115.             string $selectString;
  116.             $selectString = "select -r";
  117.  
  118.             // select all results to begin with
  119.             //
  120.             $resultCount = size($intersectResults) ;
  121.             for( $i = 0 ; $i < $resultCount ; $i++ ) {
  122.                 $selectString += " ";
  123.                 $selectString += $intersectResults[$i] ;
  124.             }
  125.             $selectString += ";";
  126.             eval($selectString) ;
  127.         }
  128.     }
  129. }
  130.